package cn.itcast.nems.listener.clazz;

import cn.itcast.nems.journal.dto.JournalClazzStartDateChangedDTO;
import cn.itcast.nems.journal.service.JournalChangeDateService;
import cn.itcast.nems.listener.NemsMessageListener;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 监听EMS修改班级-开班时间
 * </p>
 *
 * @author zhouwei
 * @since 2023/12/26 2:50 PM
 **/
@Component
@RequiredArgsConstructor
@Slf4j
public class ClazzChangeMessageListener implements NemsMessageListener {
    private final static String TagName = "TAG_CLAZZ_START_DATE_CHANGE";
    private final JournalChangeDateService journalChangeDateService;

    @Override
    public String getTagName() {
        return TagName;
    }

    @Override
    public void processMessage(String body) {
        JournalClazzStartDateChangedDTO dto = JSON.parseObject(body, JournalClazzStartDateChangedDTO.class);
        log.info("【监听班级开班时间变更消息】业务参数：{}", dto);
        this.journalChangeDateService.dateChanged(dto);
    }
}
